package com.huangfu.easysardine.gate.session;

import org.springframework.security.web.session.HttpSessionEventPublisher;
import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer;
import org.springframework.stereotype.Service;

import javax.servlet.ServletContext;

/**
 * Created with IntelliJ IDEA.
 * User: huangfu.daohui
 * Date: 2017-8-14
 * Time: 13:45
 * Description:向应用容器添加springSessionRepositoryFilter,顺便注册一下HttpSessionEventPublisher监听,
 * 这个监听的作用发布HttpSessionCreatedEvent和HttpSessionDestroyedEvent事件
 */
@Service
public class SessionApplicationInitializer extends AbstractHttpSessionApplicationInitializer {
    @Override
    protected void afterSessionRepositoryFilter(ServletContext servletContext) {
        servletContext.addListener(new HttpSessionEventPublisher());
    }
}